<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/js/axios.min.js"></script>
    <script src="/js/util.js"></script>
    <script>
        window.onload = function () {
            checkLogin()
            init();
        }

        function checkLogin() {
            axios.get("/user/getLoginUser").then(resp => {
                var user = resp.data;
                // console.log(user);
                if (user != "") {
                    $("faceImg").src = "/face/" + user.head;
                    $("userNameSpan").innerHTML = user.name;
                    $("emailSpan").innerHTML = user.email;
                }
            });
        }

        function init() {
            axios.get("/channel/findAllAndCount").then(resp => {
                var list = resp.data;
                str = "";
                list.forEach(n => {
                    str += `<tr><td><a href="/mainPost.html?id=${n.id}">${n.name}</a></td><td>${n.describe}</td><td>${n.count}</td></tr>`
                })
                $("data").innerHTML = str;
            });
        }
    </script>
</head>
<body>
<div>
    <img src="" id="faceImg" width="50px" height="50px"><br>
    用户名：<span id="userNameSpan"></span><br>
    用户邮箱：<span id="emailSpan"></span>
</div>
<div>
    <table border="1xp" width="80%">
        <thead>
        <tr>
            <td>频道名称</td>
            <td>频道描述</td>
            <td>主贴数量</td>
        </tr>
        </thead>
        <tbody id="data">

        </tbody>
    </table>
</div>
</body>
</html>